﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Pass3_2 : MonoBehaviour
{
    public CtrlStep[] ctrlSteps;
    private int currentIndex = 0;
    public Text tipTxt;
    public bool isOver = false;

    private void Start()
    {
        for (int i = 0; i < ctrlSteps.Length; i++)
        {
            ctrlSteps[i].isOver = false;
           
        }
        ctrlSteps[currentIndex].Init();
        tipTxt.text = ctrlSteps[currentIndex].tipStr;
    }


    private void Update()
    {
        if (!isOver) { CheckNext(); };
      
    }

    private void CheckNext()
    {
        if(currentIndex< ctrlSteps.Length)
        {

            ctrlSteps[currentIndex].UpdateAction();

            if (ctrlSteps[currentIndex].isOver)
            {
                if (currentIndex < ctrlSteps.Length-1)
                {
                    currentIndex++;
                    ctrlSteps[currentIndex].Init();

                    tipTxt.text = ctrlSteps[currentIndex].tipStr;
                }
                else
                {
                    Debug.Log("通关");
                    EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true);
                    isOver = true;

                }


            }
        }

       
    }

}
